﻿// -----------------------------------------------------------------------
//  <copyright file="UpdateSettingCommand.cs" company="LiuliuSoft">
//      Copyright (c) 2025 66SOFT. All rights reserved.
//  </copyright>
//  <site>https://ifs.66soft.net</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2025-10-08 17:10</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Domain;
using DaprPlus.Mapping;
using DaprPlus.Settings.Domain.Dtos;
using DaprPlus.Settings.Domain.Entities;
using DaprPlus.Settings.Domain.Services;


namespace DaprPlus.Settings.Application.Commands;

public class UpdateSettingCommand(SettingDefinitionInDto dto) : IRequest<ApiResult>
{
    public SettingDefinitionInDto Dto { get; } = dto;
}

public class UpdateSettingCommandHandler(ISettingStore store) : IRequestHandler<UpdateSettingCommand, ApiResult>
{
    public async Task<ApiResult> Handle(UpdateSettingCommand request, CancellationToken cancellationToken)
    {
        var result = await store.SaveSettingAsync(request.Dto, cancellationToken);
        return result;
    }
}